﻿<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="utf-8"/>
    <title>集群Hadoop构建</title>

    <meta name="keywords" content="Bootstrap模版,Bootstrap模版下载,Bootstrap教程,Bootstrap中文"/>
    <meta name="description" content="站长素材提供Bootstrap模版,Bootstrap教程,Bootstrap中文翻译等相关Bootstrap插件下载"/>
    <meta name="viewport" content="width=device-width, initial-scale=1.0"/>

    <!-- basic styles -->

    <link href="../static/assets/css/bootstrap.min.css" rel="stylesheet"/>
    <link rel="stylesheet" href="../static/assets/css/font-awesome.min.css"/>

    <!--[if IE 7]>
    <link rel="stylesheet" href="../static/assets/css/font-awesome-ie7.min.css"/>
    <![endif]-->

    <!-- page specific plugin styles -->

    <link rel="stylesheet" href="../static/assets/css/jquery-ui-1.10.3.full.min.css"/>
    <link rel="stylesheet" href="../static/assets/css/datepicker.css"/>
    <link rel="stylesheet" href="../static/assets/css/ui.jqgrid.css"/>

    <!-- fonts -->

    <!--<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300" />-->

    <!-- ace styles -->

    <link rel="stylesheet" href="../static/assets/css/ace.min.css"/>
    <link rel="stylesheet" href="../static/assets/css/ace-rtl.min.css"/>
    <link rel="stylesheet" href="../static/assets/css/ace-skins.min.css"/>

    <!--[if lte IE 8]>
    <link rel="stylesheet" href="../static/assets/css/ace-ie.min.css"/>
    <![endif]-->

    <!-- inline styles related to this page -->

    <!-- ace settings handler -->

    <script src="../static/assets/js/ace-extra.min.js"></script>

    <!-- HTML5 shim and Respond.js IE8 support of HTML5 elements and media queries -->

    <!--[if lt IE 9]>
    <script src="../static/assets/js/html5shiv.js"></script>
    <script src="../static/assets/js/respond.min.js"></script>
    <![endif]-->
</head>

<body>
<div class="navbar navbar-default" id="navbar">
    <script type="text/javascript">
        try {
            ace.settings.check('navbar', 'fixed')
        } catch (e) {
        }
    </script>

    <div class="navbar-container" id="navbar-container">
        <div class="navbar-header pull-left">
            <a href="#" class="navbar-brand">
                <small>
                    <i class="icon-leaf"></i>
                    Ace Admin
                </small>
            </a><!-- /.brand -->
        </div><!-- /.navbar-header -->

        <div class="navbar-header pull-right" role="navigation">
            <ul class="nav ace-nav">
                <li class="light-blue">
                    <a data-toggle="dropdown" href="#" class="dropdown-toggle">
                        <img class="nav-user-photo" src="../static/assets/avatars/user.jpg" alt="Jason's Photo"/>
                        <span class="user-info">超级管理员</span>
                        <i class="icon-caret-down"></i>
                    </a>
                    <ul class="user-menu pull-right dropdown-menu dropdown-yellow dropdown-caret dropdown-close">
                        <li>
                            <a href="#">
                                <i class="icon-cog"></i>
                                设置
                            </a>
                        </li>
                        <li>
                            <a href="#">
                                <i class="icon-user"></i>
                                个人中心
                            </a>
                        </li>
                        <li class="divider"></li>
                        <li>
                            <a href="#">
                                <i class="icon-off"></i>
                                退出
                            </a>
                        </li>
                    </ul>
                </li>
            </ul><!-- /.ace-nav -->
        </div><!-- /.navbar-header -->
    </div><!-- /.container -->
</div>

<div class="main-container" id="main-container">
    <script type="text/javascript">
        try {
            ace.settings.check('main-container', 'fixed')
        } catch (e) {
        }
    </script>

    <div class="main-container-inner">
        <a class="menu-toggler" id="menu-toggler" href="#">
            <span class="menu-text"></span>
        </a>

        <div class="sidebar" id="sidebar">
            <script type="text/javascript">
                try {
                    ace.settings.check('sidebar', 'fixed')
                } catch (e) {
                }
            </script>

            <div class="sidebar-shortcuts" id="sidebar-shortcuts">
                <div class="sidebar-shortcuts-large" id="sidebar-shortcuts-large">
                    <button class="btn btn-success">
                        <i class="icon-signal"></i>
                    </button>

                    <button class="btn btn-info">
                        <i class="icon-pencil"></i>
                    </button>

                    <button class="btn btn-warning">
                        <i class="icon-group"></i>
                    </button>

                    <button class="btn btn-danger">
                        <i class="icon-cogs"></i>
                    </button>
                </div>

                <div class="sidebar-shortcuts-mini" id="sidebar-shortcuts-mini">
                    <span class="btn btn-success"></span>

                    <span class="btn btn-info"></span>

                    <span class="btn btn-warning"></span>

                    <span class="btn btn-danger"></span>
                </div>
            </div><!-- #sidebar-shortcuts -->

            <ul class="nav nav-list">
                <li>
                    <a href="/index">
                        <i class="icon-dashboard"></i>
                        <span class="menu-text"> 监控大屏 </span>
                    </a>
                </li>

                <li>
                    <a href="#" class="dropdown-toggle open">
                        <i class="icon-edit"></i>
                        <span class="menu-text"> 一键部署 </span>

                        <b class="arrow icon-angle-down"></b>
                    </a>
                    <ul class="submenu" style="display: block;">
                        <li>
                            <a href="/struction">
                                <img style="width: 35px;height: 35px;" src="../static/assets/avatars/hadoop.png" alt="">
                                Hadoop单机版
                            </a>
                        </li>
                        <li class="active">
                            <a href="/structionCluster">
                                <img style="width: 35px;height: 35px;" src="../static/assets/avatars/hadoop.png" alt="">
                                Hadoop集群版
                            </a>
                        </li>
                        <li>
                            <a href="form-wizard.html">
                                <img style="width: 30px;height: 30px;" src="../static/assets/avatars/flink.png" alt="">
                                &nbsp;Flink单机版
                            </a>
                        </li>
                    </ul>
                </li>
            </ul><!-- /.nav-list -->

            <div class="sidebar-collapse" id="sidebar-collapse">
                <i class="icon-double-angle-left" data-icon1="icon-double-angle-left"
                   data-icon2="icon-double-angle-right"></i>
            </div>

            <script type="text/javascript">
                try {
                    ace.settings.check('sidebar', 'collapsed')
                } catch (e) {
                }
            </script>
        </div>

        <div class="main-content">
            <div class="breadcrumbs" id="breadcrumbs">
                <script type="text/javascript">
                    try {
                        ace.settings.check('breadcrumbs', 'fixed')
                    } catch (e) {
                    }
                </script>

                <ul class="breadcrumb">
                    <li>
                        <i class="icon-home home-icon"></i>
                        <a href="#">一键部署</a>
                    </li>
                    <li class="active">Hadoop集群</li>
                </ul><!-- .breadcrumb -->

                <div class="nav-search" id="nav-search">
                    <form class="form-search">
								<span class="input-icon">
									<input type="text" placeholder="Search ..." class="nav-search-input"
                                           id="nav-search-input" autocomplete="off"/>
									<i class="icon-search nav-search-icon"></i>
								</span>
                    </form>
                </div><!-- #nav-search -->
            </div>

            <div class="page-content">
                <ul class="nav nav-tabs" style="height: 50px;width: 71%;margin: 0 auto;">
                    <li class="active" ><a href="#tab1" data-toggle="tab">表单模式</a></li>
                    <li><a href="#tab2" data-toggle="tab">导入模式</a></li>
                    <li>
                        <a href="#">XXX</a></li>
                    <li>
                        <a href="#">YYY</a></li>
                    <li>
                        <a href="#">ZZZ</a></li>
                    <li class="dropdown">
                        <a class="dropdown-toggle" data-toggle="dropdown" href="#">KKK
                            <span class="caret"></span></a>
                        <ul class="dropdown-menu">
                            <li>
                                <a href="#">QQQ</a></li>
                            <li>
                                <a href="#">WWW</a></li>
                            <li>
                                <a href="#">EEE</a></li>
                            <li class="divider"></li>
                            <li>
                                <a href="#">RRR</a></li>
                        </ul>
                    </li>
                    <li>
                        <a href="#">TTT</a></li>
                </ul>
                <div class="tab-content" style="width: 71%;margin: 0 auto;">
                    <div id="tab1" class="tab-pane fade in active" style="position: relative;">
                        <button id="addNode" style="right: 20px;position: absolute;" class="btn-sm btn btn-primary">增加节点</button>
                        <!-- 表单模式 -->
                        <h3 style="width: 87%;color: red;font-size: 14px;">集群模式推荐至少三个节点！NameNode、SecondaryNameNode、ResourceManager对资源的需求比较大，应该把他们三个分布到不同的机器上！</h3>
                        <form id="form">
                            <div style="margin-top: 1%;">
                                <input style="width: 20%;display: inline-block;" type="text" class="form-control ip" placeholder="请输入服务器IP">
                                <select id="type1" style="width: 20%;height: 34px;display: inline-block;" class="form-control type">
                                    <option selected disabled>请选择节点类型</option>
                                    <option value="NameNode">NameNode</option>
                                    <option value="DataNode">DataNode</option>
                                    <option value="SecondaryNameNode">SecondaryNameNode</option>
                                    <option value="ResourceManager">ResourceManager</option>
                                    <option value="NodeManager">NodeManager</option>
                                </select>
                                <input style="width: 20%;display: inline-block;" type="text" class="form-control username" placeholder="用户名">
                                <input style="width: 20%;display: inline-block;" type="password" class="form-control password" placeholder="登录密码">
                            </div>
                            <div style="margin-top: 1%;">
                                <input style="width: 20%;display: inline-block;" type="text" class="form-control ip" placeholder="请输入服务器IP">
                                <select id="type1" style="width: 20%;height: 34px;display: inline-block;" class="form-control type">
                                    <option selected disabled>请选择节点类型</option>
                                    <option value="NameNode">NameNode</option>
                                    <option value="DataNode">DataNode</option>
                                    <option value="SecondaryNameNode">SecondaryNameNode</option>
                                    <option value="ResourceManager">ResourceManager</option>
                                    <option value="NodeManager">NodeManager</option>
                                </select>
                                <input style="width: 20%;display: inline-block;" type="text" class="form-control username" placeholder="用户名">
                                <input style="width: 20%;display: inline-block;" type="password" class="form-control password" placeholder="登录密码">
                            </div>
                            <div style="margin-top: 1%;">
                                <input style="width: 20%;display: inline-block;" type="text" class="form-control ip" placeholder="请输入服务器IP">
                                <select id="type1" style="width: 20%;height: 34px;display: inline-block;" class="form-control type">
                                    <option selected disabled>请选择节点类型</option>
                                    <option value="NameNode">NameNode</option>
                                    <option value="DataNode">DataNode</option>
                                    <option value="SecondaryNameNode">SecondaryNameNode</option>
                                    <option value="ResourceManager">ResourceManager</option>
                                    <option value="NodeManager">NodeManager</option>
                                </select>
                                <input style="width: 20%;display: inline-block;" type="text" class="form-control username" placeholder="用户名">
                                <input style="width: 20%;display: inline-block;" type="password" class="form-control password" placeholder="登录密码">
                            </div>
                        </form>

                    </div>
                    <div id="tab2" class="tab-pane fade">
                        <!-- 导入模式 -->
                        <form class="form-inline" role="form">
                            <div class="form-group">
                                <label class="sr-only" for="inputfile">文件输入</label>
                                <input type="file" id="inputfile">
                            </div>
                            <button onclick="downLoadExcel()" class="btn btn-info btn-sm">下载导入模板</button>
                        </form>
                    </div>
                </div>


                    <div class="form-group" style="margin-top: 10px;margin-left: 39%;margin-right: 39%;">
                        <div class="col-sm-offset-2 col-sm-10">
                            <button type="button" id="commit" class="btn btn-danger">立即部署</button>
                        </div>
                    </div>

                <table class="table" style="width: 71%;margin: 7% auto;">
                    <thead>
                    <tr>
                        <th>目标服务器IP</th>
                        <th>日志位置</th>
                        <th>类型</th>
                        <th>执行状态</th>
                        <th>执行时间</th>
                    </tr>
                    </thead>
                    <tbody id="content">
                    </tbody>
                </table>
                <ul style="float: right;margin-right: 15%;margin-top: -5%;" class="pagination">
                    <li><a href="#">&laquo;</a></li>
                    <li><a href="#">1</a></li>
                    <li><a href="#">2</a></li>
                    <li><a href="#">3</a></li>
                    <li><a href="#">4</a></li>
                    <li><a href="#">5</a></li>
                    <li><a href="#">&raquo;</a></li>
                </ul>
                </div><!-- /.row -->
            </div><!-- /.page-content -->
        </div><!-- /.main-content -->
    <script src="../static/assets/js/jquery-1.10.2.min.js"></script>
    <script>
        function downLoadExcel(){
            window.location.href="http://localhost:8080/downloadExcel";
        }

        $('#tab1').on('click','#del',function(){
            $(this).parent().remove();
        });

        $("#addNode").click(function (){
            $("#form").append(' <div style="margin-top: 1%;">\n' +
                '                                <input style="width: 20%;display: inline-block;" type="text" class="form-control ip" placeholder="请输入服务器IP">\n' +
                '                                <select id="type1" style="width: 20%;height: 34px;display: inline-block;" class="form-control type">\n' +
                '                                    <option selected disabled>请选择节点类型</option>\n' +
                '                                    <option value="NameNode">NameNode</option>\n' +
                '                                    <option value="DataNode">DataNode</option>\n' +
                '                                    <option value="SecondaryNameNode">SecondaryNameNode</option>\n' +
                '                                    <option value="ResourceManager">ResourceManager</option>\n' +
                '                                    <option value="NodeManager">NodeManager</option>\n' +
                '                                </select>\n' +
                '                                <input style="width: 20%;display: inline-block;" type="text" class="form-control username" placeholder="用户名">\n' +
                '                                <input style="width: 20%;display: inline-block;" type="password" class="form-control password" placeholder="登录密码">\n' +
                '                            <button id="del" class="btn-small" style="display: inline-block;">删除</button>\n' +
                '                            </div>');
        });
        function getData(){
            $.get(
                "/logList",
                {"logType":"构建Hadoop集群"},
                function (data2) {
                    var data = JSON.parse(data2)
                    tempStr = '';
                    for(var i=0;i<data.length;i++){
                        var status = data[i].log_status
                        if(status == "SUCCESS"){
                            tempStr+=' <tr class="success">\n' +
                                '                        <td>'+data[i].target_ip+'</td>\n' +
                                '                        <td><a target="_blank" href="/download?fileName='+data[i].log_url+'">'+data[i].log_url+'</a></td>\n' +
                                '                        <td>'+data[i].log_type+'</td>\n' +
                                '                        <td style="font-weight: bold;">'+data[i].log_status+'</td>\n' +
                                '                        <td>'+data[i].log_time+'</td>\n' +
                                '                    </tr>';
                        }else{
                            tempStr+=' <tr class="danger">\n' +
                                '                        <td>'+data[i].target_ip+'</td>\n' +
                                '                        <td><a target="_blank" href="/download?fileName='+data[i].log_url+'">'+data[i].log_url+'</a></td>\n' +
                                '                        <td>'+data[i].log_type+'</td>\n' +
                                '                        <td style="font-weight: bold;">'+data[i].log_status+'</td>\n' +
                                '                        <td>'+data[i].log_time+'</td>\n' +
                                '                    </tr>';
                        }
                        $("#content").html(tempStr)
                    }
                }
            );
        }
        $(function (){
            getData()
        });
        $("#commit").click(function () {
            var isSubmit = true;
            var ipArray = new Array()
            var typeArray = new Array()
            var usernameArray = new Array()
            var passwordArray = new Array()
            $(".ip").each(function(){
               var currentVal = $(this).val()
                if(currentVal==""){
                    isSubmit = false;
                    return false;
                }
                ipArray.push(currentVal)
            });
            $(".type").each(function(){
                var currentVal = $(this).val()
                if(currentVal==null){
                    isSubmit = false;
                    return false;
                }
                typeArray.push(currentVal)
            });
            $(".username").each(function(){
                var currentVal = $(this).val()
                if(currentVal==""){
                    isSubmit = false;
                    return false;
                }
                usernameArray.push(currentVal)
            });
            $(".password").each(function(){
                var currentVal = $(this).val()
                if(currentVal==""){
                    isSubmit = false;
                    return false;
                }
                passwordArray.push(currentVal)
            });
            if(isSubmit){
                $("#commit").html("部署中..")
                $("#commit").removeClass("btn-danger")
                $("#commit").addClass("btn-warning")

                $.post(
                    "/hadoop_cluster_form?ipArray="+ipArray+"&typeArray="+typeArray+"&usernameArray="+usernameArray+"&passwordArray="+passwordArray,
                    function (data) {
                        var obj = JSON.parse(data)
                        // alert(JSON.stringify(data))
                        if(obj.code==200){
                            alert("处理完毕！部署详情查看下方日志！")
                            getData()
                        }else{
                            alert("ERROR! 发生错误!")
                        }
                        $("#commit").html("立即部署")
                        $("#commit").removeClass("btn-warning")
                        $("#commit").addClass("btn-danger")
                    }
                );
            }else{
                alert("信息必须填写完整！")
            }
        });
    </script>

    </div><!-- /.main-container-inner -->

    <a href="#" id="btn-scroll-up" class="btn-scroll-up btn btn-sm btn-inverse">
        <i class="icon-double-angle-up icon-only bigger-110"></i>
    </a>
</div><!-- /.main-container -->
<script type="text/javascript">
    window.jQuery || document.write("<script src='../static/assets/js/jquery-2.0.3.min.js'>" + "<" + "/script>");
</script>

<script type="text/javascript">
    window.jQuery || document.write("<script src='assets/js/jquery-1.10.2.min.js'>" + "<" + "/script>");
</script>
<script type="text/javascript">
    if ("ontouchend" in document) document.write("<script src='../static/assets/js/jquery.mobile.custom.min.js'>" + "<" + "/script>");
</script>
<script src="../static/assets/js/bootstrap.min.js"></script>
<script src="../static/assets/js/typeahead-bs2.min.js"></script>
<script src="../static/assets/js/date-time/bootstrap-datepicker.min.js"></script>
<script src="../static/assets/js/jqGrid/jquery.jqGrid.min.js"></script>
<script src="../static/assets/js/jqGrid/i18n/grid.locale-en.js"></script>
<script src="../static/assets/js/ace-elements.min.js"></script>
<script src="../static/assets/js/ace.min.js"></script>
</body>
</html>
